package com.hdaccp.hbase;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.util.Bytes;

//使用HBase Java API删除scores表中jason1的math课程成绩
public class DeleteCourse {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Configuration conf=HBaseConfiguration.create();//环境信息
		Connection conn=ConnectionFactory.createConnection(conf);//数据库连接
		Table table= conn.getTable(TableName.valueOf("scores"));//得到表的实例
		Delete del=new Delete(Bytes.toBytes("jason1"));		//删除行键jason1的操作实例
		del.deleteColumn(Bytes.toBytes("course"),Bytes.toBytes("math"));//添加列键信息。也可以	del.addColumn(Bytes.toBytes("course"),	 Bytes.toBytes("math"));
		table.delete(del);//执行删除
		conn.close();//关闭连接
	}

}
